package com.hsp.try_;

import java.util.Scanner;

//让用户输入整数才能退出
public class TryExercise04 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        //
        String inPut = "";
        int num = 0;
        while (true) {
            try {
                System.out.println("请输入一个整数");
                inPut = scanner.next();
                num = Integer.parseInt(inPut);
                break;
            } catch (NumberFormatException e) {

            }
        }
        System.out.println("你输入的整数为=" + num);
    }
}

